<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use App\User;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Auth;
use DB;
use Mail;
class PersonController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        // echo 111;
        if(empty(Auth::user()->id)){
            return view('/auth/login');
        }else{
           $count0=DB::table('order')->where(['uid'=>Auth::user()->id,'order_status'=>0])->count();
           $count1=DB::table('order')->where(['uid'=>Auth::user()->id,'order_status'=>1])->count();
           $count2=DB::table('order')->where(['uid'=>Auth::user()->id,'order_status'=>2])->count();
           $count3=DB::table('order')->where(['uid'=>Auth::user()->id,'order_status'=>3])->count();
           $refund=DB::table('order')->where(['uid'=>Auth::user()->id,'refund'=>1])->count();
           $id=Auth::user()->id;
           return view('home.person_index')->with('count0',$count0)
                                           ->with('count1',$count1)
                                           ->with('count2',$count2)
                                           ->with('count3',$count3)
                                           ->with('refund',$refund)
                                           ->with('id',$id); 
        }                   
        
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }


}
